package com.zx.ticket.service.serviceImpl;

import com.zx.ticket.dao.MovieMapper;
import com.zx.ticket.entity.Movie;
import com.zx.ticket.service.MovieService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MovieServiceImpl implements MovieService {

    @Autowired
    private MovieMapper movieMapper;

    @Override
    public int addMovie(Movie movie) {

        //Movie movie = new Movie();
        movieMapper.addMovie(movie.getName(),
                movie.getEname(),
                movie.getType(),
                movie.getCountry(),
                movie.getDuration(),
                movie.getShowtime(),
                movie.getScore(),
                movie.getVotes(),
                movie.getIntroduce(),
                movie.getDirectorId(),
                movie.getPerformerId(),
                movie.getImg(),
                movie.getImages());
        return 1;
    }

    @Override
    public int deleteMovie(int id) {

        return movieMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Movie> findAll(Movie movie) {
        return movieMapper.findAll(movie);
    }

    @Override
    public void updateByPrimaryKey(Movie movie)

    {
        movieMapper.updateByPrimaryKey(movie);
    }

    @Override
    public List<Movie> findById(Integer id) {
        return movieMapper.findById(id);
    }
}
